#ifndef PLAYER_HH
#define PLAYER_HH

#include "../include/ICharacter.hh"
#include "../include/Item.hh"
#include <vector>

namespace Game {
    class Player : public ICharacter {
    public:
        enum Class { WARRIOR, MAGE, ROGUE };

        Player();
        Player(const std::string& name, Class playerClass);
        Player(const Player& other);
        Player& operator=(const Player& other);
        ~Player() override = default;

        // ICharacter implementation
        bool isAlive() const override;
        void takeDamage(int damage) override;
        void attack(ICharacter& target) override;
        std::string getName() const override;
        unsigned getHealth() const override;
        unsigned getAttack() const override;
        unsigned getDefense() const override;
        void addItem(Item* item) override;
        void displayInventory() const override;

        // Unique methods
        const std::vector<std::unique_ptr<Item>>& getInventory() const;
        std::unique_ptr<Item> generateDrop() const override;
        std::unique_ptr<ICharacter> clone() const override;
        void gainExp(unsigned exp);
        void levelUp();
        void showStats() const;
        bool tryEscape();
        void useItem(int index);
        unsigned calculateDamage(unsigned targetDefense) const;
        unsigned getInventorySize() const;

    private:
        std::string name_;
        Class class_;
        unsigned health_;
        unsigned maxHealth_;
        unsigned attack_;
        unsigned defense_;
        unsigned exp_ = 0;
        unsigned expToNextLevel_ = 100; // Dynamic EXP requirement
        unsigned level_ = 1;//player level
        double criticalChance_ = 0.1;
        std::vector<std::unique_ptr<Item>> inventory_;
        std::vector<std::unique_ptr<Item>> equippedItems_;
    };
}

#endif